package com.rainliang.project.user.basic.service.impl;

import com.rainliang.project.user.basic.bean.LoginBean;
import com.rainliang.project.user.basic.bean.RegistBean;
import com.rainliang.project.user.basic.bean.UserBean;
import com.rainliang.project.user.basic.bean.UserInfo;
import com.rainliang.project.user.basic.dao.UserDao;
import com.rainliang.project.user.basic.service.UserService;
import com.rainliang.project.util.MD5Util;

public class UserServiceImpl implements UserService {

	private UserDao userDao;
	public UserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}
	
	
	@Override
	public Long addUser(UserBean userBean) {
		// TODO Auto-generated method stub
		return userDao.addUser(userBean);
	}

	@Override
	public UserBean getUserById(Long userId) {
		// TODO Auto-generated method stub
		return userDao.getById(userId);
	}

	@Override
	public UserInfo login(LoginBean loginBean) {
		if(loginBean==null)return null;
		loginBean.setPassword(MD5Util.getMD5String(loginBean.getPassword()));
		return userDao.login(loginBean);
	}

	public UserInfo register(RegistBean registBean){
		return userDao.register(registBean);
	}
	
	@Override
	public UserInfo loginById(Long userId) {
		// TODO Auto-generated method stub
		return userDao.getUserInfoById(userId);
	}

	
}
